cmake_minimum_required(VERSION 3.0.2)
project(zhz_drivers)

# set(OpenCV_DIR /usr/local/opencv3416/share/OpenCV)
# set(cv_bridge_DIR /usr/local/opencv3416/cv_bridge/share/cv_bridge/cmake)
# file(GLOB_RECURSE OPENCV420 "/usr/lib/x86_64-linux-gnu/libopencv*")
# file(GLOB_RECURSE OPENCV3416 "/usr/local/opencv3416/lib/libopencv*")

# set(CMAKE_PREFIX_PATH /usr/local/opencv3416/)
# link_directories(/usr/local/opencv3416/lib)
set(CMAKE_CXX_STANDARD 14)
add_compile_options("-O3" "-funsafe-loop-optimizations" "-fsee" "-funroll-loops" "-fno-math-errno" "-funsafe-math-optimizations" "-ffinite-math-only" "-fno-signed-zeros")


find_package(Eigen3 REQUIRED)
find_package(OpenCV REQUIRED)

find_package(catkin REQUIRED COMPONENTS
  cmake_modules
  cv_bridge
  geometry_msgs
  image_geometry
  image_transport
  message_generation
  nodelet
  pluginlib
  roscpp
  sensor_msgs
  std_msgs
  tf
)



# export LD_LIBRARY_PATH=/usr/local/opencv3416/lib:$LD_LIBRARY_PATH
# set(ALIBS 
#   /usr/local/opencv3416/lib/libopencv_core.so.3.4
#   /usr/local/opencv3416/lib/libopencv_imgproc.so.3.4
#   /usr/local/opencv3416/lib/libopencv_calib3d.so.3.4
#   /usr/local/opencv3416/lib/libopencv_highgui.so.3.4
#   /usr/lib/x86_64-linux-gnu/libopencv_core.so.4.2
#   /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.4.2
#   /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.4.2,
#   /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.4.2,
# )

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS
    roscpp
)

# list(REMOVE_ITEM catkin_LIBRARIES ${OPENCV420})
###########
## Build ##
###########

include_directories(include
  ${catkin_INCLUDE_DIRS}
  ${EIGEN3_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)

file(GLOB SRCS
  "src/*.h"
  "src/*.cc"
  "src/*.cpp"
)

# message(${OpenCV_INCLUDE_DIRS})
# message(${OpenCV_LIBS})
# message("==============")
# message(${OpenCV_LIBRARIES})
add_executable(camera_node ${SRCS})
target_link_libraries(camera_node ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
# add_executable(${PROJECT_NAME} ${SRCS})
# target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})



#############
## Install ##
#############

# install(DIRECTORY include/${PROJECT_NAME}/
#   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
#   FILES_MATCHING PATTERN "*.h"
# )

# install(DIRECTORY config launch
#   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
# install(FILES nodelet_plugins.xml
#   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

# install(TARGETS
#   ${PROJECT_NAME}_common
#   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
#   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
#   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# )

# install(PROGRAMS scripts/analyze_image DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})